<?php
	include "C:/xampp/htdocs/jrckeditor/db_edit/dbinfo.inc.php";
	$text = $_POST['text'];
	$did = $_POST['did'];
	
	
	mysql_connect($hostname, $username, $password, FALSE);
	@mysql_select_db($database) or die("Unable to select database");
	
	$result = mysql_query('SELECT MAX( id ) as max FROM ' . $edit_table . ' WHERE did = ' . $did);
	if (mysql_numrows($result) == 0) {
		echo "No edits for user did: " . $did;
		return;
	}
	$lastedit = 0;
	while ($row = mysql_fetch_array($result)) {
		$lastedit = $row['max'];
	}
	
	$query = 'UPDATE `' . $database . '`.`' . $doc_table . '` ';
	$query .='SET `text` = \'' . $text . '\' , `lastedit` = ' . $lastedit;
	$query .= ' WHERE id = ' . $did ;
	
	$result = mysql_query($query);
	
	
	
	if (!$result) {
		die('Invalid query: ' . mysql_error());
	}
	mysql_close();
?>